<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c:if test="${Role=='student' }">
<%@ include file="header_student.jsp"%>
</c:if>
<c:if test="${Role=='teacher' }">
<%@ include file="header_teacher.jsp"%>
</c:if>
<c:if test="${Role=='admin' }">
<%@ include file="header_admin.jsp"%>
</c:if>
<div class="left-sidebar">
	<div class="row-fluid">
		<div class="span2"></div>

		<div class="span10">

			<div class="span5"></div>
			<div class="span4">
				<span class="label label-success"><h2>${roomid }</h2></span>
			</div>
			<div class="span2"></div>
			<div class="widget">

				<div class="widget-header">
					<div class="span12">
						<div class="span3"></div>
						<div class="span3">容纳人数：${room.BSize }</div>
						<div class="span3">
							<c:choose>
								<c:when test="${room.media == 1}">
        							是否有多媒体：是
    							</c:when>
								<c:otherwise>
    								是否有多媒体：否
    							</c:otherwise>
							</c:choose>
						</div>
						<div class="span3">
							<button type="button" class="btn btn-info btn-lg"
								onclick="window.location.href='/mycms/room/book'">重置</button>
						</div>
					</div>

				</div>

				<div class="widget-body">
					<form id="saveroom" action="/mycms/room/saveroom" method="post">

						<input type="hidden" id="roomid" name="roomid" value="${roomid }">
						<input type="hidden" id="date" name="date" value=""> <input
							type="hidden" id="time" name="time" value="">
						<table
							class="table table-condensed table-striped table-bordered table-hover no-margin">
							<thead>
								<tr>
									<th></th>
									<c:forEach items="${timelist }" var="time">
										<th style="width:20%;text-align:center">${time.start }~
											${time.end }</th>
									</c:forEach>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${datelist }" var="bookdate">
									<tr>
										<td style="text-align:center">${bookdate }</td>
										<c:forEach items="${timelist }" var="time">
											<td class="hidden-phone" style="text-align:center">
											<c:set var="judge" value="${0 }"/>
												<c:forEach
													items="${orderroom }" var="orderroom">
													<c:if
														test="${fn:contains(orderroom.orderDate, bookdate) && orderroom.orderTime == time.TId && orderroom.state != 2}">
														<%-- <c:if test="${orderroom.state == 1 || orderroom.state == 3  }">
															
														</c:if> --%>
														<c:set var="judge" value="${1 }" />
														
													</c:if>
												</c:forEach> 
												<c:choose>
													<c:when test="${judge == 1}">
														<button type='button' class='btn btn-danger'
															disabled='disabled'>不可预约</button>
													</c:when>
													<c:otherwise>
														<button type='button' class='btn btn-success'
															onclick="saveroom('${bookdate}',${time.TId})">预约</button>
													</c:otherwise>
												</c:choose>
												</td>
										</c:forEach>

									</tr>
								</c:forEach>
							</tbody>
						</table>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	function saveroom(date, time) {

		document.getElementById('date').value = date;
		document.getElementById('time').value = time;
		document.getElementById('saveroom').submit();

	}
</script>
<jsp:include page="footer.jsp"></jsp:include>
